CREATE  PROCEDURE  getTinMacCaMoiTheoNguoiBan
@MaNguoiBan CHAR(10)
AS
SELECT  TOP  1 *  FROM  dbo.TinMacCa WHERE  MaTaiKhoanNhan =  @MaNguoiBan ORDER  BY  NgayGui DESC
GO

--SET STATISTICS TIME ON

--DROP INDEX idx_getTinMacCaMoiTheoNguoiBan ON dbo.TinMacCa

--EXEC getTinMacCaMoiTheoNguoiBan 'KH24166977'
CREATE NONCLUSTERED INDEX idx_getTinMacCaMoiTheoNguoiBan ON dbo.TinMacCa(MaTaiKhoanNhan, NgayGui)
--EXEC getTinMacCaMoiTheoNguoiBan 'KH24166977'
--GO

-------------------------------------------------------------------

CREATE PROCEDURE getGiaoDichNapTien
@MaNguoiGiaoDich CHAR(10)
AS
	SELECT TOP 1 * FROM dbo.GiaoDichNapTien WHERE MaKhachHang = @MaNguoiGiaoDich ORDER BY ThoiGianNap DESC
GO

--SET STATISTICS TIME ON

--DROP INDEX idx_getGiaoDichNapTien ON dbo.GiaoDichNapTien

--EXEC getGiaoDichNapTien 'KH90902435'
CREATE NONCLUSTERED INDEX idx_getGiaoDichNapTien ON dbo.GiaoDichNapTien(MaKhachHang, ThoiGianNap)
--EXEC getGiaoDichNapTien 'KH90902435'